package com.one.service.impl;

import com.one.bean.User;
import com.one.mapper.UserIntegralMapper;
import com.one.service.UserIntegralService;
import com.one.util.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
  * @author : zzh
  * @date : 2022/1/14
  * @return :
  * @description : 用户积分实现类
 */
@Service
public class UserIntegraltService implements UserIntegralService {

    @Autowired
    private UserIntegralMapper userIntegralMapper;

    @Autowired
    private RedisUtils redisUtils;

    /**
      * @author : zzh
      * @date : 2022/1/14
      * @return :
      * @description : 根据用户id增加指定用户积分
     */
    @Override
    public int updateUserIntegral(Integer userId, Integer integral) {
        User user = new User();
        //获取user的id与现有积分
        user.setId(userId);
        user.setIntegral(integral);
        return userIntegralMapper.updateById(user);
    }
}
